package com.unitd.base.frame.plugin.log.factory;

import com.unitd.base.frame.plugin.log.LogSucceed;
import com.unitd.base.frame.plugin.log.LogType;
import com.unitd.base.module.test.po.OperationLog;

import java.util.Date;

/**
 * 日志对象创建工厂
 *
 * @author Hudan
 * @version 1.0
 * @filename LogFactory.java
 * @copyright www.unitd.com
 * @date 2020-06-29
 */
public class LogFactory {

    /**
     * 创建操作日志
     *
     * @param logType       日志类型
     * @param userId        记录日志的用户
     * @param bussinessName 业务名称
     * @param clazzName     产生日志的类名
     * @param methodName    产生日志的方法名
     * @param msg           日志详细信息
     * @param succeed       是否成功
     * @return 日志对象
     */
    public static OperationLog createOperationLog(LogType logType, Long userId, String bussinessName, String clazzName, String methodName, String msg, LogSucceed succeed) {
        OperationLog operationLog = new OperationLog();
        operationLog.setLogType(logType.getMessage());
        operationLog.setLogName(bussinessName);
        operationLog.setUserId(userId);
        operationLog.setClassName(clazzName);
        operationLog.setMethod(methodName);
        operationLog.setCreateTime(new Date());
        operationLog.setSucceed(succeed.getMessage());
        operationLog.setMessage(msg);
        return operationLog;
    }
}